<?php

namespace App\Http\Resources\SiteLocation;

use App\Enums\OpenShop\InvestmentPromotion\SiteLocationEnum;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class SiteLocationCustomerAnalysisResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param Request $request
     * @return array
     */
    public function toArray($request): array
    {
        return array_merge($this->resource->toArray(), [
            "time"                         => formatDateYmd($this->time),
            "afternoonYoungProportionText" => translateEnumCodeToCn(SiteLocationEnum::CUSTOMER_ANALYSIS_TEXT,
                $this->afternoonYoungProportion, ""),
            "afternoonTeaYoungProportion"  => translateEnumCodeToCn(SiteLocationEnum::CUSTOMER_ANALYSIS_TEXT,
                $this->afternoonTeaYoungProportion, ""),
            "nightYoungProportion"         => translateEnumCodeToCn(SiteLocationEnum::CUSTOMER_ANALYSIS_TEXT,
                $this->nightYoungProportion, ""),
            "nightSnackYoungProportion"    => translateEnumCodeToCn(SiteLocationEnum::CUSTOMER_ANALYSIS_TEXT,
                $this->nightSnackYoungProportion, ""),
        ]);
    }
}
